<?php
namespace App\Services\Fund\FundBorrowLog;
use App\Services\Fund\ValidateFundBorrowLog;
use App\Models\Fund\FundBorrowLog;
class FundBorrowLogLogic
{
    // 所有用户资金借款日志分页数据
    public function list(array $data): array
    {
        $where['status'] = 1;
        $res = FundBorrowLog::where($where)
                     ->orderBy('id', 'desc')
                     ->paginate($data['list_rows'], null, null, $data['page'])
                     ->toArray();
        return auto_return_page($res, '已找到用户资金借款日志', '没有用户资金借款日志');
    }
    // 获取某些user_ids的的资金借款日志(分页)
    public function listByUserIds(array $data): array
    {
        $where['status'] = 1;
        $res = FundBorrowLog::where($where)
                     ->whereIn('user_id',[$data['user_ids']])
                     ->orderBy('id', 'desc')
                     ->paginate($data['list_rows'], null, null, $data['page'])
                     ->toArray();
        return auto_return_page($res, '已找到用户资金借款日志', '没有用户资金借款日志');
    }
    // 获取某个用户某个状态的资金借款日志分页数据
    public function listByUserType(array $data): array
    {
        $res = FundBorrowLog::where([['status','=',1],['user_id','=',$data['user_id']],['refund_status','=',$data['refund_status']]])
                     ->orderBy('id', 'desc')
                     ->paginate($data['list_rows'], null, null, $data['page'])
                     ->toArray();
        return auto_return_page($res, '已找到用户资金借款日志', '没有用户资金借款日志');
    }
}